<template>
    <div class="cont">
      <!--<loading></loading>-->
      <div class="head1">
        <p class="dataclo">建议或意见反馈</p>
      </div>
      <p>这间店铺的牛排不够新鲜</p>
      <p>这间店铺的调料种类太少了</p>
      <p v-for="item in items"> {{item}}&nbsp;</p>
      <div>
        <el-input class="areatxt"   type="textarea" :rows="10" placeholder="请填写需要提交的建议或意见内容" v-model="tijiao"></el-input>
      </div>
      <div class="btncon">
        <div class="btncon-1">
          <el-button type="button" value='提交' @click="gotijiao" class="ti">提交</el-button>&nbsp;&nbsp;&nbsp;&nbsp;
 
            <el-button type="button" value='清空' class="kong"  @click="qingkong">清空</el-button>
          
        </div>
      </div>
    </div>
</template>

<script type="text/javascript">
import loading from "@/components/loading";
import axios from "axios";
export default {
  inject:['reload'],
  data() {
    return {
      tijiao: "",
      items: []
    };
  },
  // computed: {
  //   items() {
  //     return this.$store.state.items;
  //   }
  // },
  mounted() {
    /*axios({
      method: "get", // 请求方法
      url: "http://localhost:8088/tijiao", //请求地址
      data: {
        //请求参数
        tijiao: this.tijiao
      },
      headers: {
        //请求头
        "Content-type": "text/plain"
      }
    }).then(response => {
      console.log(response.data);
      // this.items = response.data;
      this.$store.commit("items", response.data);
      
    });*/
    axios({
      method: "post", // 请求方法
      url: "http://localhost:8088/tijiao", //请求地址
      data: {
        //请求参数
        tijiao: this.tijiao
      },
      headers: {
        //请求头
        "Content-type": "text/plain"
      }
    }).then(
      //数据返回后的回调函数
      response => {
        alert(response.data);
      },
      err => {
        //数据发生错误执行的函数
        console.log(err);
      }
    );
  },
  methods: {
    data() {
      return {};
      components: {
        loading;
      }
    },
    gotijiao() {
      if (this.tijiao == "") return alert("请填写你所反馈的意见");
      this.$store.commit("items", this.tijiao);
      this.items = this.$store.state.items;

      
    },
    goqingkong(){
      this.reload();
    }
  }
};
</script>
<style scoped>
@import "../../css/feedback.css";
</style>
